<template>
  <!-- 对话框客户跟进记录 -->
  <el-dialog
    title="客户跟进记录"
    :visible="followEditDialog"
    :close-on-click-modal="false"
    center
    @close="closeFollowEditDialog"
    width="50%"
  >
    <el-input
      type="textarea"
      placeholder="请输入跟进内容"
      :rows="5"
      v-model="textareaValue"
      maxlength="200"
      show-word-limit
    >
    </el-input>
    <span slot="footer" class="dialog-footer">
      <el-button @click="closeFollowEditDialog">取 消</el-button>
      <el-button type="primary" @click="editFollowApi">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { editFollowApi } from '@/api/company'
export default {
  name: 'edit-dialog',
  props: {
    followEditDialog: {
      type: Boolean,
      default: false
    },
    company_id: {
      type: Number,
      default: 0
    }
  },
  created () {},
  data () {
    return {
      textareaValue: ''
    }
  },
  methods: {
    closeFollowEditDialog () {
      this.$emit('closeFollowEditDialog')
      // 清空文本域
      this.textareaValue = ''
    },
    // 编辑跟进业务记录
    async editFollowApi () {
      if (this.textareaValue === '') {
        return this.$message({
          showClose: true,
          message: '请输入跟进记录!',
          type: 'warning',
          duration: 1500
        })
      }
      const { data: res } = await editFollowApi(
        this.company_id,
        this.textareaValue
      )
      // console.log('编辑跟进业务记录', res)
      if (res.code === 200) {
        this.$message({
          showClose: true,
          message: '编辑成功!',
          type: 'success',
          duration: 1500
        })
        this.closeFollowEditDialog()
      }
    }
  },
  watch: {}
}
</script>

<style lang="scss">
.el-dialog {
  .el-dialog__header {
    background-color: rgb(84, 92, 100);
    padding: 20px 20px 20px;
    .el-dialog__title {
      color: #fff;
    }
  }
}
</style>
